package player.ui.video;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JWindow;

import net.miginfocom.swing.MigLayout;

import player.PS;

public class VideoFrame extends JWindow{
	
	private static final long serialVersionUID = 9130059048170643362L;

	PS player;
	public VideoFramePanel framePanel;
	VideoFrameRootPanel VideoFrameRootPanel;
	//GlassWindowTop GlassWindowTop;
	int topWinH=20;
	int butonWinH=10;
	int lrW=10;
	public boolean isFullSereen=false;
	Rectangle orgRec;
	public VideoFrame(JFrame mframe){
		super(mframe);
		//com.sun.awt.AWTUtilities.setWindowOpaque(this, false);
		this.player=player;
		//GlassWindowTop=new GlassWindowTop();
		JComponent glassPane=(JComponent) getRootPane().getGlassPane();
		glassPane.setLayout(null);
		JButton b=new JButton("HHHHHHHHHHH");
		glassPane.add(b);
		b.setBounds(50,50,50,50);
		
	}
	
	public void switchFullScreen(){
		setFullScreen(!isFullSereen);
	}
	
	public void setFullScreen(boolean b){
		isFullSereen=b;
		if(isFullSereen){
			orgRec=this.getBounds();
			Dimension dm=Toolkit.getDefaultToolkit().getScreenSize();
			Rectangle f=new Rectangle();
			f.width=dm.width;
			f.height=dm.height;
			setBounds(f);
		}else{
			this.setBounds(orgRec);
		}
	}
	
	
	
	public long getWid(){
		return framePanel.getWid();
	}
	
	public void setVisible(boolean b){
		super.setVisible(b);
		//GlassWindowTop.setVisible(b);
	}
	
	public void init(){
		framePanel=new VideoFramePanel();
		VideoFrameRootPanel=new VideoFrameRootPanel(framePanel);
		setContentPane(VideoFrameRootPanel);
	}
	
	public void addDragComponent(Component cp){
		new FrameDrag(this,cp);
	}
	
	public void setLocation(Point point){
		Point rec2=new Point();
		rec2.x=point.x;
		rec2.y=point.y-topWinH;
		//GlassWindowTop.setLocation(rec2);
		super.setLocation(point);
		
		PS.checkFloatPanelLocation();
	}
	
	public void setBounds(Rectangle rec){
		Rectangle rec2=new Rectangle();
		rec2.width=rec.width+2*lrW;
		rec2.height=topWinH+butonWinH+getHeight();
		rec2.x=rec.x-lrW;
		rec2.y=rec.y-topWinH;
		//GlassWindowTop.setBounds(rec2);
		super.setBounds(rec);
		PS.checkFloatPanelLocation();
	}
	
}
